//
//  UIView+Layer.m
//  TLUIKit
//
//  Created by c on 2021/10/27.
//

#import "UIView+Layer.h"

@implementation UIView (Layer)

- (void)setBorderColor:(UIColor *)borderColor {
    self.layer.borderColor = borderColor.CGColor;
}

- (UIColor *)borderColor {
    return [UIColor colorWithCGColor:self.layer.borderColor];
}

- (void)setBorderWidth:(CGFloat)borderWidth {
    self.layer.borderWidth = borderWidth;
}

- (CGFloat)borderWidth {
    return self.layer.borderWidth;
}

- (void)setCornerRadius:(CGFloat)cornerRadius {
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = cornerRadius;
}

- (CGFloat)cornerRadius {
    return self.layer.cornerRadius;
}

- (void)roundCorners:(UIRectCorner)corners radiue:(CGFloat)radiue {
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(radiue, radiue)];
    CAShapeLayer *shape = [[CAShapeLayer alloc]init];
    shape.path = maskPath.CGPath;
    self.layer.mask = shape;
}

- (void)shadow:(UIColor *)color opacity:(float)opacity offset:(CGSize)offset radius:(CGFloat)radius {
    self.layer.shadowColor = color.CGColor;
    self.layer.shadowOpacity = opacity;
    self.layer.shadowOffset = offset;
    self.layer.shadowRadius = radius;
}

- (void)addLineViewWithFrame:(CGRect)rect color:(UIColor*)color {
    UIView *lineView = [[UIView alloc]initWithFrame:rect];
    lineView.backgroundColor = color;
    [self addSubview:lineView];
}

@end
